﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects;

namespace EnheimGallery.DAL
{
    public class PhotoStatsData
    {
        public string Name;
        public string CategoryName;
        public string OwnerUser;
        public DateTime AddedDate;
        public DateTime LastSeen;
        public int Width;
        public int Height;
        public int FileSize;

    }
    public static class PhotosStatisticsDAL
    {
       
        public static List<PhotoStatsData> PhotosStatistics()
        {
            EnheimGalleryDatabaseEntities db=new EnheimGalleryDatabaseEntities();
            string photoQuery =  @"select p.Name,c.Name,u.UserName,
                                    p.AddedDate,p.LastSeen
                                    from Photos p
                                    join Categories c on p.CategoryId=c.Id
                                    join aspnet_Users u on u.UserId=c.OwnerId
                                    order by p.AddedDate";
            ObjectResult<PhotoStatsData> queryResult = db.ExecuteStoreQuery<PhotoStatsData>(photoQuery);
            List<PhotoStatsData> statisticsData = queryResult.ToList();

            return statisticsData;
        }
    }
}
